Skip to content

Fix for SWs with same Action= shadowing each other - #69

Open
Templarfreak wants to merge 1 commit into
OpenTS-Developers:mainfrom
Templarfreak:SW-Shadowing-Fix
Open

Fix for SWs with same Action= shadowing each other#69
Templarfreak wants to merge 1 commit into
OpenTS-Developers:mainfrom
Templarfreak:SW-Shadowing-Fix

Conversation

@Templarfreak

Copy link
Copy Markdown

Summary

SWs that have the same Action type shadow each other due to pulling which superweapon the player is targeting via From_Action, which only returns the first entry that matches the action. This adds new player state that tracks what the last SW the player started targeting and uses that instead. The new state gets cleaned up when the SW fires or the player clears the targeting mode. The value gets initialized and serializes.

Behavior and compatibility

This should remain fully backwards compatible, no changes to vanilla rules needed for it to continue working as expected.

Validation

Player having access to multiple Superweapons with the same Action= at the same time should now work properly.

Documentation

N/A

Checklist

  • The change is focused; unrelated mechanical cleanup is separate
  • Compatibility effects and any migration are explicit
  • A player- or modder-visible engine change carries its change record
  • Validation distinguishes what passed, failed, and was not run
  • No prohibited assets, binaries, SDKs, credentials, or generated output are included

SWs that have the same Action type shadow each other due to pulling which superweapon the player is targeting via `From_Action`, which only returns the first entry that matches the action. This adds new player state that tracks what the last SW the player started targeting and uses that instead.
@Templarfreak

Templarfreak commented Aug 29, 2026

Copy link
Copy Markdown
Author

launchsite->LastSuperWeaponIndex = Class->Type;

this could also be relevant in the future but it doesnt seem to affect anything noticeable right now.

edit: well it's entirely unused anyway actually so it's weird, whatever lol

@JoyfulShush

Copy link
Copy Markdown

Very nice improvement for sure. Great work!

Few considerations to take into account:

  • Is there a ts-patches or Vinifera fix for this? I ask because DTA has a few missions where a player can have access to 2 or more nukes (which, as far as I know, are different SWs carrying the same Action=), so maybe it was already implemented in some way and it would be better to implement that instead.
  • Is this desync-safe? Since PlayerPtr is local state that may affect gameplay. As long as it produces an event that all sides participate in, should be okay, but worth making sure.
  • What about an AI having multiple SWs of the same type? Is it bugged for it as well? If so, may be worth fixing it generally, rather than only local player.

@Templarfreak

Copy link
Copy Markdown
Author

Very nice improvement for sure. Great work!

Few considerations to take into account:

* Is there a ts-patches or Vinifera fix for this? I ask because DTA has a few missions where a player can have access to 2 or more nukes (which, as far as I know, are different SWs carrying the same Action=), so maybe it was already implemented in some way and it would be better to implement that instead.

* Is this desync-safe? Since PlayerPtr is local state that may affect gameplay. As long as it produces an event that all sides participate in, should be okay, but worth making sure.

* What about an AI having multiple SWs of the same type? Is it bugged for it as well? If so, may be worth fixing it generally, rather than only local player.

loose fields on PlayerPtr already contributed to the code path, and from what i can tell the only thing that actually matters is constructing the event and pushing it into OutList which behaves exactly the same as before. PlayerPtr is the local player, but by constructing the event and pushing it into OutList, it syncs the event action for everyone from what i can tell. so this should be MP safe!

i dont think Vinifera made a fix for this, at least it's not mentioned in changelogs / documentation anywhere it seems. AI seems to think Vinifera's reimplemented sidebar maybe could have fixed it, which sounds somewhat plausible. either way, can you double-check how DTA is doing that in that context? because it seems like it probably didnt patch that and is doing something else interesting. apparently it's common to use an EMP SW as an extra alternative and i found that being mentioned in a super old Vini issue but no idea if that's relevant to what you're describing

also traced by AI but: game AI has a totally different codepath for using / targeting(?) their SWs and from what i can tell actually doesnt have the same bug, so whatever changes to AI targeting superweapons that may want to be made should be for another PR probably?

i did actually also miss a few things so i'll probably make another commit to this to patch up a few areas. there's other places IsTargettingMode is cleared but i am not clearing TargetingSW apparently where it might matter.

@JoyfulShush

Copy link
Copy Markdown

either way, can you double-check how DTA is doing that in that context?

Turns out it's multiple SWs with the same Type=, but they have their own Action=.

However, I did notice that if the player fires multiple SW in a very short amount of time, it will cause the coordinates of the targeting to be overridden, making 2 or more of the missiles hit the same coordinate instead of what the player actually did. However, it does mean you have to do it very quickly to see this bug.

Possibly your changes will also fix that?

@Templarfreak

Copy link
Copy Markdown
Author

im not 100% sure on that, all i have changed here is how the SW being used for targeting gets piped into the event, in theory that kind of setup should just be identical to how this would function, but just this doesnt need to do a workaround like that (and would not be limited by how many Action types there are).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants